﻿@model ClientsViewModel

@{
	ViewBag.Title = @Html.GetGlobalResource("PagesTitles", "AdminClients");
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
//    System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
}

<h2>@Html.GetGlobalResource("PagesTitles", "AdminClients")</h2>
<table>
	<tr>
		<th>@Html.GetLocalResource("Login")</th>
		<th>@Html.GetLocalResource("LastActivityDate")</th>
		<th>@Html.GetLocalResource("Email")</th>
		<th>@Html.GetLocalResource("Balance")</th>
		<th>@Html.GetLocalResource("Actions")</th>
	</tr>
	@foreach (var item in Model.Clients) {
		var user = Membership.GetUser(item.MembershipUser.UserName);
		if (user != null) {
			<tr>
                @if(!user.IsApproved){
                    <td class="NoApprovedUsers">@user.UserName</td>
                }
                else
                {
                    <td class="ApprovedUsers">@user.UserName</td>
                }
				
				<td>@user.LastActivityDate.ToString("dd MMMM yyyy HH:mm")</td>
				<td>@user.Email</td>
				<td>@Html.GetCurrencyString(item.Finance != null ? item.Finance.Total : 0)</td>
				<td>
					@if (item.UserId == Model.CurrentMembershipUser.UserId) {
						<label>@Html.GetLocalResource("InvalidAction")</label>
					}
					else {
						if (!user.IsApproved) {
							using (Html.BeginForm("UnlockClient", "Admin", new {login = user.UserName, loginFilter = Model.LoginFilter}, FormMethod.Post, new {style = "float: left;"})) {
								<input type="submit" value="@Html.GetLocalResource("Unlock")"/>
							}
						}
						else {
							using (Html.BeginForm("LockClient", "Admin", new {login = user.UserName, loginFilter = Model.LoginFilter}, FormMethod.Post, new {style = "float: left;"})) {
								<input type="submit" value="@Html.GetLocalResource("Lock")"/>
							}
						}
						using (Html.BeginForm("DeleteClient", "Admin", new {userId = item.UserId, loginFilter = Model.LoginFilter}, FormMethod.Post, new {style = "float: left;"})) {
							<input type="submit" value="@Html.GetLocalResource("Delete")"/>
							@Html.HttpMethodOverride(HttpVerbs.Delete)
						}
					}
				</td>
			</tr>
		}
	}
</table>
<br/><br/>
@Html.Partial("_LoginFilter", new LoginFilterViewModel {Action = "Clients", Controller = "Admin"})